package com.graduation.fq.student.Logic;

import com.graduation.fq.student.Args.CourseCheckEventArgs;
import com.graduation.fq.student.Process.CourseCheckProcess;
import com.graduation.fq.student.interfaces.EventListener;
import com.graduation.fq.student.interfaces.ResponseListener;

/**
 * Created by jifang
 * Time 2016/5/27 15:28.
 */
public class CourseCheckLogic extends BaseLogic {

    private static CourseCheckLogic instance;

    public static CourseCheckLogic getInstance() {
        if (instance == null) {
            instance = new CourseCheckLogic();
        }
        return instance;
    }

    public void getAllCourse(final EventListener listener) {
        final CourseCheckProcess process = new CourseCheckProcess();
        process.runGet(new ResponseListener() {
            @Override
            public void onResponse(String requestId) {
                CourseCheckEventArgs args = new CourseCheckEventArgs(process.getStatus(), process.getCourses());
                fireEvent(args, listener);
            }
        });
    }

    public void getCourseByCredit(Integer credit, final EventListener listener) {
        final CourseCheckProcess process = new CourseCheckProcess(credit);
        process.runGet(new ResponseListener() {
            @Override
            public void onResponse(String requestId) {
                CourseCheckEventArgs args = new CourseCheckEventArgs(process.getStatus(), process.getCourses());
                fireEvent(args, listener);
            }
        });
    }
}
